/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
****************************************************************************/

#include <qstatusbar.h>
#include <qmessagebox.h>
#include <qmenubar.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qimage.h>
#include <qtimer.h>

#include "canvas.h"
#include "descargar.h"

#include <stdlib.h>

extern QString data_fn;
extern QString ack_fn;
extern QString rtt_fn;
extern QString rttcal_fn;
extern QString rttwire_fn;

int main(int argc, char** argv)
{
    Q_INIT_RESOURCE(portedcanvas);
    Q_INIT_RESOURCE(resources);

    QApplication app(argc,argv);

    if ( argc > 1 )
        data_fn = argv[1];
    else
        ack_fn = "datos/ACKsGrafica.png";
    
    if ( argc > 2 )
        ack_fn = argv[2];
    else
        data_fn = "datos/DATApktsGrafica.png";

    if ( argc > 3 )
        rtt_fn = argv[3];
    else
        rtt_fn = "datos/RTTsGrafica.png";
    if ( argc > 4 )
           rttcal_fn = argv[4];
       else
           rttcal_fn = "datos/RTTs1+estimadosGrafica.png";
    if ( argc > 5 )
           rttwire_fn = argv[5];
       else
           rttwire_fn = "datos/RTTs2+estimadosGrafica.png";
    QGraphicsScene canvas;
    canvas.setSceneRect(0, 0, 1180, 700);
    Main m(canvas);
    m.resize(m.sizeHint());
    m.setCaption("Plataforma de Estadisticas RAD'S 3.0");
    if ( QApplication::desktop()->width() > m.width() + 10
	&& QApplication::desktop()->height() > m.height() +30 )
        m.showMaximized();
    else
	m.showMaximized();
    
    QTimer timer;
    QObject::connect(&timer, SIGNAL(timeout()), &canvas, SLOT(advance()));
    timer.start(30);

    QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) );
    
    return app.exec();
}

